﻿using System;
using System.IO;
using System.Text;

namespace JinianNet.Common
{
    public class Path
    {
        public static string Concat(params string[] args)
        {
            string dsc = System.IO.Path.DirectorySeparatorChar.ToString();
            string dscs = string.Concat(dsc, dsc);
            if (args == null || args.Length == 0)
                return null;
            return Utils.Replace(string.Join(dsc, args).Replace("/", dsc), dscs, dsc);
        }

        public static string Combine(params string[] args)
        {
            return System.IO.Path.Combine(args);
        }

        public static string GetDirectoryPath(string path)
        {
            return System.IO.Path.GetDirectoryName(path);
        }

        public static string GetGetParentPath(string path)
        {
            return Directory.GetParent(path).FullName;
        }

        public static bool IsRootPath(string path)
        {
            return path.TrimEnd(System.IO.Path.DirectorySeparatorChar).EndsWith(System.IO.Path.VolumeSeparatorChar.ToString());
        }
    }
}
